<?php
/**
 * Created by PhpStorm.
 * User: w
 * Date: 2016/5/27
 * Time: 11:05
 */
//会议视频--子类的构造方法会报错
class Meet_videoController extends BaseController{

    //会议视频主页
    function  index()
    {
        $do_meet_video = new Do会议视频();
        $do_meet = new Do会议表();

        $do_meet_video->leftJoin($do_meet, 'b', 'b.id=a.meet_id');
        $meet_video_count = $do_meet_video->fields('count(a.id)')->getOneField();
        $page_meet_video = new tools\Page($meet_video_count, 15);
        $meet_video_list = $do_meet_video->fields('a.*,b.name hname')->orderby(' id desc')->rows();
        $url_form_video = $this->url('meet_video', 'form_meet_video');
        require $this->template;
    }

    //会议视频表单处理
    function form_meet_video(){
        $do_meet=new Do会议表();
        $do_meet_video=new Do会议视频();
        if($_POST){
            //会议表编号
            $meet_name=$this->request('会议名称','',true);
            $a=explode('-',$meet_name);
            $title = $this->request('title','', true);
            $url = $this->request('url','', true);

            $主讲人 = $this->request('主讲人','', true);
            $播放时长 = $this->request('播放时长','', true);
            $nowtime = $this->request('nowtime','', true);

            if(array_key_exists('群id', $_REQUEST) and $_REQUEST['群id']){
                $do_meet_video->set_群id($_REQUEST['群id']);
                $do_meet_video->where($do_meet_video->data)->row();

            } else {
                $操作人id = $this->request('操作人id',"",true);

                //创建群组
                $qun = new C群聊天('');
                $qun_id = $qun->fj建课程群($操作人id);

                $do_meet_video->set_群id($qun_id);
                $do_meet_video->set_操作人id($操作人id);
            }

            $do_meet_video->set_title($title);
            $do_meet_video->set_nowtime($nowtime);
            $do_meet_video->set_播放时长($播放时长);
            $do_meet_video->set_主讲人($主讲人);
            $do_meet_video->set_meet_id($a[1]);
            $do_meet_video->set_url($url);
            $url_index=$this->url('meet_video','index');

            if($do_meet_video->save()){
                echo "<script>alert('提交成功');location.href='".$url_index."'</script>";
            }else{
                echo "<script>alert('提交失败');</script>";
            }
        }else{
            $huiyi_res=$do_meet->rows();
            if($_REQUEST['id']){
                $do_meet_video->leftJoin($do_meet,'b','b.id=a.meet_id');
                $huiyi_shipin_detail=$do_meet_video->fields('a.*,b.id yid ,b.name name')->where(array('a.id'=>$_REQUEST['id']))->rows();
            }
           require  $this->template;
        }

    }
}